<template>
    <bi-table :data="list" :loading="loading" tree item-key="cate_id" height="369" :storagename="$user.getStorageName('shop-design-cate')" >   
        <bi-table-column label="ID" name="cate_id" width="100"></bi-table-column>
        <bi-table-column label="分类名称" name="title" tree-fold ></bi-table-column>
        <bi-table-column label="操作" width="80" v-slot="{row}">
            <bi-button type="primary" size="small" @click="select(row)" >选择</bi-button>
        </bi-table-column>
    </bi-table>
</template>

<script>
export default{
    emits:['callback'],
    data(){
        return {
            list:[],
            loading:false
        }
    },
    methods:{
        getList(){
            this.loading = true;
            this.$ajax({
                url:this.$url({controller:'admin.cate',action:'tree'}),
                success:(res)=>{
                    this.loading = false;
                        this.list = res.tree;
                    }
            });
        },
        select(row){
            this.$emit('callback','CATE#'+row.cate_id,row.title);
        }
    },
    mounted(){
        this.getList();
    }
    
}
</script>